import { useState, memo, useCallback, useReducer } from 'react';

import './App.css';

var state;

function App() {
  const [count, setCount] = useState(0);
  const cleanCount = useCallback(function() {
    setCount(0);
  }, []);
  return (
    <div>
      <span>{count}</span>
      <button onClick={() => setCount(count+1)}>+1</button>
      <Foo cleanCount={cleanCount} />
    </div>
  );
}

const Foo = memo(function({cleanCount}) {
  return (
    <>
      <p>子组件</p>
      <button onClick={cleanCount}>清零</button>
    </>
  )
})

export default App;
